<template>
  <div>
<!--    <h1>问题管理</h1>-->
    <template>
      <el-table
          :data="tableData"
          style="width: 100%">
        <el-table-column
            label="日期"
            width="180">
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.created }}</span>
          </template>
        </el-table-column>

        <el-table-column
            label="问题"
            width="360">
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.question }}</span>
          </template>
        </el-table-column>


        <el-table-column
            label="回答数"
            width="180">
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.answerCount }}</span>
          </template>
        </el-table-column>

        <el-table-column label="操作"
                         align="right">
          <template slot-scope="scope">
            <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.row.qid)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </template>

<!--&lt;!&ndash;    <el-pagination class="mpage"&ndash;&gt;-->
<!--&lt;!&ndash;                   background&ndash;&gt;-->
<!--&lt;!&ndash;                   layout="prev, pager, next"&ndash;&gt;-->
<!--&lt;!&ndash;                   :current-page="currentPage"&ndash;&gt;-->
<!--&lt;!&ndash;                   :page-size="pageSize"&ndash;&gt;-->
<!--&lt;!&ndash;                   :total="total"&ndash;&gt;-->
<!--&lt;!&ndash;                   @current-change=page>&ndash;&gt;-->
<!--&lt;!&ndash;    </el-pagination>&ndash;&gt;-->
  </div>

</template>

<script>
export default {
  name: "quesManage",
  data() {
    return {
      tableData: [],
      // currentPage: 1,
      // total: 0,
      // pageSize: 10
    }
  },
  methods: {
    handleDelete(qid) {
      this.$axios.post("/delQues/"+qid).then(res=>{

        this.$message({
          type: 'success',
          message: '删除成功'
        })

      })
    },
    // page(currentPage) {
    //   const _this = this
    //   _this.$axios.get("/getQues").then(res => {
    //     // console.log('结果测试' + res)
    //     //这里json数据 不是直接的res.data.data 因为还包括了分页数等等
    //     _this.tableData = res.data.data
    //
    //   })
    // },
  },

  created() {
    // this.page(1);

    this.$axios.get("/getQues").then(res=>{
      this.tableData = res.data.data
    })
  }
}
</script>

<style scoped>
.mpage {
  margin: 0 auto;
  text-align: center;
}
</style>